package cc.vv.btpartyjob.partymanager.delegate

import android.widget.TextView
import cc.vv.baselibrary.view.BaseTopBarView
import cc.vv.btpartyjob.jnimodule.server.OperationServer
import cc.vv.btpartyjob.partymanager.R
import cc.vv.btpartyjob.partymanager.inter.YQApplyTimeClickInterface
import cc.vv.btpartyjob.partymanager.moudel.bean.ProjectDetailJieDuanObj
import cc.vv.btpartyjob.partymanager.view.ProjectDetailEditView
import cc.vv.mvp.delegate.BaseAppDelegate
import java.util.*

/**
 * 延期申请托管类
 * Created by Chen.qi on 2018/10/24.
 */
class ProjectPostponeApplyActivityDelegate : BaseAppDelegate() {

    override fun initWidget() {

    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_postpone_apply
    }

    /**设置标题title*/
    fun setTopBarTitle(topBarTitle: String) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_ppaA_topBar)
        titleBar?.setTitle(topBarTitle)
    }


    /**设置标题右边按钮点击事件*/
    fun setTitleBackBtnOnClick(event: BaseTopBarView.EventInterface) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_ppaA_topBar)
        titleBar?.setEventInterface(event)
    }

    /**
     * 项目进程
     */
    fun setProjectProessJieDuan(optionList: ArrayList<ProjectDetailJieDuanObj>?, applyInterface: YQApplyTimeClickInterface) {
        val projectJieduan = getView<ProjectDetailEditView>(R.id.pde_ppaA_data)
        projectJieduan?.addAllSelectedFileView(optionList, applyInterface)
    }

    /**
     * 设置项目内容
     */
    fun setZhengTiData(content: String?, yjTime: String?, completeTime: String?, state: Int?) {
        val tvContent = getView<TextView>(R.id.tv_ppaA_projectContent)
        val tvYJTime = getView<TextView>(R.id.tv_ppaA_projectWarningTime)
        val tvCompleteTime = getView<TextView>(R.id.tv_ppaA_planCompleteDate)
        val tvState = getView<TextView>(R.id.tv_ppaA_projectStatus)

        tvContent?.text = content
        tvYJTime?.text = OperationServer.formatStr(yjTime)
        tvCompleteTime?.text = OperationServer.formatStr(completeTime)
        when (state) {
            0 -> {
                tvState?.text = "未开始"
            }
            1 -> {
                tvState?.text = "进行中"
            }
            2 -> {
                tvState?.text = "已完成"
            }
        }
    }

    /**
     * 设置项目整体预计时间
     */
    fun setZhentTiYJTime(time: String?) {
        val tvYJTime = getView<TextView>(R.id.tv_ppaA_yuJinTimeOne)
        tvYJTime?.text = time
    }


    /**
     * 设置项目整体预计时间
     */
    fun setZhentTiCompleteTime(time: String?) {
        val tvComplete = getView<TextView>(R.id.tv_ppaA_yuJinTimeTwo)
        tvComplete?.text = time
    }

    /**
     * 获取延期原因
     */
    fun getYQReason(): String {
        val tvComplete = getView<TextView>(R.id.et_ppaA_cancelReason)
        return tvComplete?.text.toString().trim()
    }

}